<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<%@include file="/common/head.jsp" %>

<c:set var="module" value="designer"/>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
		<form action="${ctx }/admin/user/designerSaveNew?id=${n.id }&user.id=${n.user.id }" id="detail-form" class="form-horizontal" method="post">
			<div class="form-group">
                 <label class="col-sm-2 control-label">手机号码</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="mobile" value="${n.user.mobile }">
                 </div>
             </div>	
			
             <div class="form-group">
                 <label class="col-sm-2 control-label">真实姓名</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="realName" value="${n.user.realName }">
                 </div>
             </div>
             
             <div class="form-group">
                 <label class="col-sm-2 control-label">性别</label>
                 <div class="col-sm-10">
                 	${enum:detail('Sex', 'sex', n.user.sex) }
                 </div>
             </div>
             
             <div class="form-group">
                 <label class="col-sm-2 control-label">头像</label>
                 <div class="col-sm-10">
                 	<input type="hidden" name="headImage" id="headImage" value="${n.user.headImage }" />
                 	<div class="my-images" single="true" images="${n.user.headImage }" id="headImage1" field="headImage">
                 </div>
             </div>		
			
			<c:if test="${companyId == null }">
			<div class="form-group">
                 <label class="col-sm-2 control-label">公司</label>
                 <div class="col-sm-10">
                 	<input type="hidden" id="company-id" name="companyId" value="${query.company.id }" class="form-control">
									<input type="text"  placeholder="装修公司" class="form-control" name="company.name" id="company-name" value="${query.company.name }" 
										onclick="bring({
											url:'${ctx}/admin/company/list',
											name: 'name',
											idInput: 'company-id',
											nameInput: 'company-name'
										})" />

                 </div>
             </div>	
             </c:if>
			<div class="form-group">
                 <label class="col-sm-2 control-label">从业年限</label>
                 <div class="col-sm-10">
                 	<input type="number" class="form-control" name="workAge" value="${n.workAge }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">服务范围</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="serviceArea" value="${n.serviceArea }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">擅长风格</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="goodAtStyles" value="${n.goodAtStyles }">
                 </div>
             </div>	
			
        	<div class="form-group">
                 <label class="col-sm-2 control-label">简介</label>
                 <div class="col-sm-10">
                 	<textarea class="form-control" name="description" id="" cols="30" rows="10">${n.description }</textarea>
                 </div>
             </div>
             <!-- 装修公司的话，只能选择是否推荐 -->
             <c:if test="${empty companyId}">
             <div class="form-group">
                 <label class="col-sm-2 control-label">是否推荐</label>
                 <div class="col-sm-10">
                 	<select name="recommend" class="form-control">
                               		<option value="">---</option>
                               		<option value="1" "${n.recommend==1 ? 'selected': '' }">推荐</option>
                               		<option value="0" "${n.recommend==0 ? 'selected': '' }">不推荐</option>
                     </select>
                 </div>
             </div>		
             </c:if>
		</form>
</div>

<%@include file="/common/foot.jsp" %>
<script type="text/javascript">
$('#provinceId').change(function() {
	var provinceId = $(this).val();
	$('#cityId').html('');
	$('#districtId').html('');
	if (provinceId != '') {
		$.ajax({
			url: "${ctx}/admin/province/findArea?provinceId=" + provinceId,
			dataType: "json",
			success: function(array) {
				$('#cityId').append('<option value="">城市</option>');
				for (var i = 0; i < array.length; i++) {
					var obj = array[i];
					var option = '<option value="' + obj.id + '">' + obj.name + '</option>';
					$('#cityId').append(option);	
				}
			}
		});
	}
	
});

$('#cityId').change(function() {
	var cityId = $(this).val();
	$('#districtId').html('');
	if (cityId != '') {
		$.ajax({
			url: "${ctx}/admin/province/findArea?cityId=" + cityId,
			dataType: "json",
			success: function(array) {
				$('#districtId').append('<option value="">地区</option>');
				for (var i = 0; i < array.length; i++) {
					var obj = array[i];
					var option = '<option value="' + obj.id + '">' + obj.name + '</option>';
					$('#districtId').append(option);	
				}
			}
		});
	}
	load_filter_user();
});

$('#districtId').change(function() {
	load_filter_user();
});

$(document).ready(function() {
	init_images('headImage1');
});
</script>
</body>
</html>
